package com.dyz.wsw.filter;

import com.dyz.wsw.common.consts.web.HttpConst;
import com.dyz.wsw.common.pojo.auth.Principal;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
import org.springframework.web.server.WebFilter;
import org.springframework.web.server.WebFilterChain;
import reactor.core.publisher.Mono;

/**
 * @author dyz
 * @date 2025/1/13 14:11
 */
@Component
public class TestFilter implements WebFilter, HttpConst {
    @Override
    public Mono<Void> filter(ServerWebExchange exchange, WebFilterChain chain) {
        Principal principal = new Principal();
        principal.setId(1L);
        principal.setUsername("admin");
        exchange.getAttributes().put(HEADER_AUTHORIZATION,principal);
        return chain.filter(exchange);
    }
}
